#Test Script of create lead
require File.dirname(__FILE__)+'/../lib//testdata/testdata.rb'
require File.dirname(__FILE__)+'/../lib/elements/Leads/element_Leads.rb'
require File.dirname(__FILE__)+'/../lib/elements/Homepage/element_Homepage.rb'
require File.dirname(__FILE__)+'/../lib/reporting.rb'
require File.dirname(__FILE__)+'/../lib/std_lib.rb'
require 'watir'
require 'watir/testcase'
require 'win32ole'
class Create_Leads < Watir::TestCase
    def test_setup
        if $ie = Watir::IE.find(:title,/Home/)
            1
        else
            OCRM_STD_LIB.login($stage,$username,$password)
        end

        #  $ie.bring_to_front
        filename  = File.basename(__FILE__).gsub(/\.rb/, "")
        #@@account_name="Tonytest"
        #@@search_in="Account Name"
        @@leadname = "Tonytest"+Time.now.strftime("%Y%m%d%H%M")
        begin
            $log=Reporting.new(File.dirname(__FILE__)+'/../doc/report/'"",filename)

        rescue
            puts $!
            puts $@
            $log.close unless $log.nil?
        end

    end
    def test_quick_create_lead
        Element::Quick_Create.quick_create_lead_link.click
        sleep 5
        $ie = Watir::IE.attach(:title,/Leads/)
        $ie.bring_to_front
        Element::QuickCreateLead.fname_text_field.set(@@leadname)
        Element::QuickCreateLead.lname_text_field.set("Chen")
        Element::QuickCreateLead.cname_text_field.set("ActiveNetwork")
        Element::QuickCreateLead.market_select_list.set("Campgrounds")
        Element::QuickCreateLead.lead_source_select_list.set("ActiveCRM")
        Element::QuickCreateLead.lead_rating_select_list.set("C")
        Element::QuickCreateLead.save_button.click
    end
    def test_convert_lead

    end

    def test_reset

    end

    def test_tear_down
        @@for = nil
        @@search_in = nil
    end
end
class NewLeads < Watir::TestCase
    def test_setup
    end

    def test_tear_down
        $log.close unless $log.nil?
    end
end